public class SolutionInterview16_10 {
    public int maxAliveYear(int[] birth, int[] death) {
        int[] f=new int[105];
        for (int i : birth) {
            f[i-1900]++;
        }
        for (int i : death) {
            f[i-1899]--;
        }
        int year=1900,max=0,now=0;
        for (int i=0;i<=100;i++){
            now+=f[i];
            if (now>max){
                year=i+1900;
                max=now;
            }
        }
        return year;
    }

    public static void main(String[] args) {
        System.out.println(new SolutionInterview16_10().maxAliveYear(new int[]{1900, 1901, 1950},new int[]{1948, 1951, 2000}));
    }
}
